/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.DragonPokerServer.Classes;

import java.util.ArrayList;
import java.util.Random;

/**
 *
 * @author Administrator
 */
public class Deck {

    private ArrayList deck;

    public Deck(){

        deck = new ArrayList();
        createNewDeck();
        randomizeDeck();


    }

    public void createNewDeck(){
        for(int i = 1; i <= 4; i++){
            for(int z = 1; z <= 13; z++){
                deck.add(new Card(z, i));
            }
        }

    }

    public void randomizeDeck(){
        ArrayList deckTemp = new ArrayList();
        while (true){
            if(deck.size() == 0)
                break;
            Random r = new Random();
            int i = 0;
            
                if(deck.size() == 1)
                    i = 0;
                else
                    i = r.nextInt(deck.size() - 1);
          
            deckTemp.add((Card)deck.get(i));
            deck.remove(i);
        }
        deck = deckTemp;
    }

    public Card getCard(){
        Random r = new Random();
        int i;
        if(deck.size() == 1)
                    i = 0;
                else
                    i = r.nextInt(deck.size() - 1);
        Card c = (Card)deck.get(i);
        deck.remove(i);
        return c;
    }

    public ArrayList<Card> getFlop(){
        ArrayList<Card> flop = new ArrayList<Card>();
        Random r = new Random();
        for(int i = 0; i < 3; i++){
            Card c = this.getCard();
            c = this.getCard();
            flop.add(c);
        }
        return flop;

    }

    public Card getTurnRiver(){
        Card c = this.getCard();
        c = this.getCard();
        return c;
    }

    public ArrayList getDeck(){
        return deck;
    }


}
